package com.zhang;

import com.zhang.domain.User;
import com.zhang.mapper.UserMapper;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
public class DemoTest1 {

    @Autowired
    private UserMapper userMapper;

    @Test
    public void test1() {

        //线程1
        User user1 = userMapper.selectById(1); //version=1
        user1.setUsername("Name_1");

        //线程2
        User user2 = userMapper.selectById(1); //version=1
        user2.setUsername("Name_2");



        userMapper.updateById(user2); //修改完成后 version=2

        userMapper.updateById(user1);





    }




}
